package com.fanrenqiji.common.mapper;

import com.fanrenqiji.common.utils.DateUtils;
import org.dozer.DozerConverter;

import java.sql.Date;

/**
 * Created by yanwt on 2017/3/29.
 */
public class DateDozerConverter extends DozerConverter<String, Date> {

    public DateDozerConverter() {
        super(String.class, Date.class);
    }

    @Override
    public Date convertTo(String source, Date destination) {
        return new Date(DateUtils.parseDate(source).getTime());
    }

    @Override
    public String convertFrom(Date source, String destination) {
        return DateUtils.formatDate(source);
    }
}
